﻿package frEngine.shader.filters.vertexFilters
{
    import __AS3__.vec.*;
    import baseEngine.core.*;
    import frEngine.shader.*;
    import frEngine.shader.filters.*;
    import frEngine.shader.filters.vertexFilters.def.*;

    public class Md5EdgeFilter extends FilterBase
    {
        private var edgeSize:Vector.<Number>;
        public var texture:Texture3D;

        public function Md5EdgeFilter()
        {
            this.edgeSize = this.Vector.<Number>([2, 0.1, 0, 1]);
            super(FilterType.EdgeFilter, FilterPriority.Md5EdgeFilter);
            return;
        }// end function

        override public function setRegisterParams(param1:Program3dRegisterInstance) : void
        {
            param1.getParamByName("{edgeSize}", true).value = this.edgeSize;
            return;
        }// end function

        override public function get programeId() : String
        {
            return "eEdgeFilter0";
        }// end function

        override public function clone() : FilterBase
        {
            return this;
        }// end function

        override public function createVertexCode(param1:Program3dRegisterInstance, param2:int) : String
        {
            var _loc_3:* = new Array();
            _loc_3.push(new ToBuilderInfo("vc0", "{edgeSize}", false, 1, this.edgeSize));
            _loc_3.push(new ToBuilderInfo("vm0", FilterName.global, true, 4));
            var _loc_4:String = "";
            _loc_4 = _loc_4 + "m33           vt0.xyz  \t\t\t{T_VetextNormal}.xyz     vm0    \t\t\t\n";
            _loc_4 = _loc_4 + "nrm           vt0.xyz       \tvt0.xyz\t\t\t\t\t\t\t\t\t\t\t\n";
            _loc_4 = _loc_4 + "mul           vt0.xyz       \tvt0.xyz\t\t\t\t\t\tvc0.x\t\t\t\t\n";
            _loc_4 = _loc_4 + "m34           {output}.xyz  \t{output}      \t\t\t\tvm0    \t\t\t\t\n";
            _loc_4 = _loc_4 + "add           {output}.xyz  \tvt0.xyz      \t\t\t\t{output}    \t\t\n";
            _loc_4 = param1.toBuild(_loc_4, _loc_3);
            param1.OpType = ECalculateOpType.ViewProj;
            return _loc_4;
        }// end function

        override public function createFragmentColor(param1:Program3dRegisterInstance, param2:Boolean) : String
        {
            var _loc_3:String = "";
            var _loc_4:* = new Array();
            _loc_4.push(new ToBuilderInfo("fc0", "{edgeColor}", false, 1, [1, 1, 1, 1]));
            _loc_3 = _loc_3 + "sub\t\t\tft0.w\t\t\t {output}.w \t\t\t{fcConst1}.y\t\n";
            _loc_3 = _loc_3 + "kil\t\t\tft0.w\t\t\t\t\t\t\t\t\t\t\t\t\t\n";
            _loc_3 = _loc_3 + "mov\t\t\t{output}\t\t fc0 \t\t\t\t\t\t\t\t\t\n";
            _loc_3 = param1.toBuild(_loc_3, _loc_4);
            return _loc_3;
        }// end function

    }
}
